#include<stdio.h>
#include<string.h>

int main(int argc,char *argv[])
{
    if (argc != 2)
    {
        printf("Usage: %s filename\n", argv[0]);
        return 1;
    }

     FILE *fp = fopen(argv[1], "r");
    if(!fp)
    {
        perror("fopen:\n");//输出失败原因
        return 1;
    }

    while(1)
    {
      char buffer[128];
      memset(buffer,0,sizeof(buffer));
      int n=fread(buffer,1,sizeof(buffer)-1,fp);
      
      if(n>0)
      {
          printf("%s",buffer);
      }
      
      if(feof(fp))//判断是否读取到文件末尾
      {
        break;
      }
    }

    fclose(fp);

    return 0;
}
